package org.merak.core.sandbox;

import flexjson.JSONSerializer;

import org.merak.core.test.model.Entity;
import org.merak.core.test.model.StyledEntity;
import org.merak.core.text.ObjectJSON;
import org.merak.core.text.ObjectNVP;

public class GeraJSON {

	//~ Methods ///////////////////////////////////////////////////////////////////
	//*****************************************************************************
	public static void main(String args[]) throws Exception {

//		TemplateFactory factory = new TemplateFactory();
//		TemplateObject  object  = factory.createTemplate(Animal.class);

//		for (TemplateProperty p : object.getProperties()) {
//			System.out.print( p.getName() );
//			System.out.print( ":" + p.getType().getSimpleName() );
//			System.out.print( " " + p.getGetter().getName());
//			System.out.print( "/" + (!p.isFinal() ? p.getSetter().getName() : "") );
//			System.out.println();
//		}

		JSONSerializer flexjson = new JSONSerializer();
		Entity[]       array    = new Entity[100000];
		Entity         entity   = new StyledEntity(24);

//		System.out.println( ObjectJSON.toJson(new Entity(24)) );
//		System.out.println( ObjectJSON.toJson(entity) );
//		System.out.println( ObjectNVP.toNVP(entity)   );

		for (int i=0; i<array.length; i++) {
			array[i] = entity;
		}
		long before,after;

		before = System.currentTimeMillis();
		flexjson.deepSerialize(array);
		after  = System.currentTimeMillis();
		System.out.println( "Flexjson " + (after - before) );

		before = System.currentTimeMillis();
		flexjson.deepSerialize(array);
		after  = System.currentTimeMillis();
		System.out.println( "Flexjson " + (after - before) );

		before = System.currentTimeMillis();
		ObjectJSON.toJson(array);
		after  = System.currentTimeMillis();
		System.out.println( "ObjectJSON " +  (after - before) );

		before = System.currentTimeMillis();
		ObjectJSON.toJson(array);
		after  = System.currentTimeMillis();
		System.out.println( "ObjectJSON " +  (after - before) );

		before = System.currentTimeMillis();
		flexjson.deepSerialize(array);
		after  = System.currentTimeMillis();
		System.out.println( "Flexjson " + (after - before) );

		before = System.currentTimeMillis();
		flexjson.deepSerialize(array);
		after  = System.currentTimeMillis();
		System.out.println( "Flexjson " + (after - before) );

		before = System.currentTimeMillis();
		ObjectJSON.toJson(array);
		after  = System.currentTimeMillis();
		System.out.println( "ObjectJSON " +  (after - before) );

		before = System.currentTimeMillis();
		ObjectJSON.toJson(array);
		after  = System.currentTimeMillis();
		System.out.println( "ObjectJSON " +  (after - before) );


		System.out.println( ObjectJSON.toJson(entity) );
		System.out.println( ObjectNVP.toNVP(entity)   );

	}
	//*****************************************************************************/

}
